﻿<shared:PageBase x:Class="Miris.HumanMilkAnalyser.WPF.MainPage"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
      xmlns:shared="clr-namespace:Miris.HumanMilkAnalyser.WPF.Shared"
      x:Name="CurrentPage"
      mc:Ignorable="d" 
      d:DesignHeight="580" d:DesignWidth="1160"
	  Title="MainPage" Style="{StaticResource DefaultPageStyle}" 
      DataContext="{Binding MainPage, Source={StaticResource Locator}}">
    <Page.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="Skins/Storyboard/PageStoryborad.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Page.Resources>
    <Grid HorizontalAlignment="Center">
        <Grid.ColumnDefinitions>
            <!-- Back Button -->
            <ColumnDefinition Width="Auto" />
            <!-- Main Content -->
            <ColumnDefinition Width="Auto" />
            <!-- Next Button -->
            <ColumnDefinition Width="Auto" />
        </Grid.ColumnDefinitions>
        <Button Margin="0,0,30,0" Width="47" Tag="/Skins/Resource/Image/Back.png" Style="{StaticResource OpacityImageButton}" Visibility="Hidden" />
        <!-- Trasparent effect Background -->
        <Border Grid.Column="1" Style="{StaticResource PageContentContainerBorder}">
            <Border Style="{StaticResource PageContentBackgroundBorder}" />
        </Border>
        <Grid Grid.Column="1" Width="1050" Height="550">
            <Grid.RowDefinitions>
                <!-- Breast milk sample -->
                <RowDefinition Height="50" />
                <!-- Breast milk stage -->
                <RowDefinition Height="50" />
                <!-- Generate sample number & Check result -->
                <RowDefinition Height="Auto" />
                <!-- Result Display -->
                <RowDefinition Height="Auto" />
                <!-- Unassigned sample number -->
                <RowDefinition />
            </Grid.RowDefinitions>
            <StackPanel Orientation="Horizontal" Height="40">
                <TextBlock Text="母乳取样：" Style="{StaticResource MainPageTextBlock}" VerticalAlignment="Center" />
                <RadioButton Margin="0,0,50,0" Padding="0,0,6,0" Content="前段" IsChecked="{Binding IsFrontMilkSample}" Style="{StaticResource BigRadioButton}" />
                <RadioButton Margin="0,0,50,0" Padding="0,0,6,0" Content="中段" IsChecked="{Binding IsMiddleMilkSample}" Style="{StaticResource BigRadioButton}" />
                <RadioButton Margin="0,0,50,0" Padding="0,0,6,0" Content="后段" IsChecked="{Binding IsEndMilkSample}" Style="{StaticResource BigRadioButton}" />
                <RadioButton Padding="0,0,6,0" Content="全乳" IsChecked="{Binding IsFullMilkSample}" Style="{StaticResource BigRadioButton}" />
            </StackPanel>
            <StackPanel Grid.Row="1" Orientation="Horizontal" Height="40">
                <TextBlock Text="母乳分期：" Style="{StaticResource MainPageTextBlock}" VerticalAlignment="Center" />
                <RadioButton Margin="0,0,50,0" Padding="0,0,6,0" Content="初乳" IsChecked="{Binding IsUnmatureMilkStage}" Style="{StaticResource BigRadioButton}" />
                <RadioButton Margin="0,0,50,0" Padding="0,0,6,0" Content="过渡乳" IsChecked="{Binding IsTransitionalMilkStage}" Style="{StaticResource BigRadioButton}" />
                <RadioButton Padding="0,0,6,0" Content="成熟乳" IsChecked="{Binding IsMatureMilkStage}" Style="{StaticResource BigRadioButton}" />
            </StackPanel>
            <StackPanel Grid.Row="2" Margin="0,30,0,0" Orientation="Horizontal">
                <Button Margin="0,0,10,0" Style="{StaticResource BigButton}" Command="{Binding GenerateSampleNumberCommand}">
                    <Button.Content>
                        <TextBlock Width="90"  Text="生    成 样本号" TextWrapping="Wrap" />
                    </Button.Content>
                </Button>
                <TextBox Width="345" FontSize="48" IsReadOnly="True" Text="{Binding GeneratedSampleNumber}" Style="{StaticResource InfoTextBox}" />
                <Button Margin="20,0,10,0" Style="{StaticResource BigButton}" Command="{Binding GetAnalysisResultCommand}">
                    <Button.Content>
                        <TextBlock Width="80" Text="测  试  结  果" TextWrapping="Wrap" />
                    </Button.Content>
                </Button>
                <TextBox Width="345" FontSize="48" Text="{Binding InputSampleNumber, UpdateSourceTrigger=PropertyChanged}" 
                         IsReadOnly="{Binding IsInputSampleNumberReadOnly}" Style="{StaticResource InfoTextBox}" />
            </StackPanel>
            <DataGrid Grid.Row="3" Margin="0,20,0,0" SelectionMode="Single" BorderThickness="1" BorderBrush="#0f1d7a" 
                      HorizontalAlignment="Left" Height="220" Width="1050" ColumnHeaderStyle="{StaticResource DefaultDataGridColumnHeader}" 
                      SelectedItem="{Binding SelectedAnalysisResult, Mode=OneWayToSource, UpdateSourceTrigger=PropertyChanged}"
                      ItemsSource="{Binding AnalysisResultList}">
                <DataGrid.Resources>
                    <SolidColorBrush Color="LightBlue" x:Key="{x:Static SystemColors.InactiveSelectionHighlightBrushKey}" />
                </DataGrid.Resources>
                <DataGrid.Columns>
                    <DataGridTextColumn Header="序号" Width="60" Binding="{Binding SequenceNumber}" />
                    <DataGridTextColumn Header="测试时间" Width="*" Binding="{Binding TestDateDisplay}" />
                    <DataGridTextColumn Header="脂肪(g/100ml)" Width="120" ElementStyle="{StaticResource TestResultDataGridCell}" Binding="{Binding Fat.TestResult}" />
                    <DataGridTextColumn Header="总蛋白质(g/100ml)" Width="140" ElementStyle="{StaticResource TestResultDataGridCell}" Binding="{Binding CrudeProtein.TestResult}" />
                    <DataGridTextColumn Header="真蛋白质(g/100ml)" Width="160" ElementStyle="{StaticResource TestResultDataGridCell}" Binding="{Binding TrueProtein.TestResult}" />
                    <DataGridTextColumn Header="糖类(g/100ml)" Width="120" ElementStyle="{StaticResource TestResultDataGridCell}" Binding="{Binding Carbohydrate.TestResult}" />
                    <DataGridTextColumn Header="干物质(g/100ml)" Width="140" ElementStyle="{StaticResource TestResultDataGridCell}" Binding="{Binding TS.TestResult}" />
                    <DataGridTextColumn Header="总能量(kcal/100ml)" Width="140" ElementStyle="{StaticResource TestResultDataGridCell}" Binding="{Binding Energy.TestResult}" />
                </DataGrid.Columns>
            </DataGrid>
            <Button Grid.Row="4" Content="未分配样本号" HorizontalAlignment="Left" Style="{StaticResource MenuButton}" Command="{Binding UnassignedSampleNumberCommand}" />
        </Grid>
        <Button Grid.Column="2" Margin="30,0,0,0" Width="47" Tag="/Skins/Resource/Image/Next.png" Style="{StaticResource OpacityImageButton}" Command="{Binding NextCommand}" />
    </Grid>
</shared:PageBase>
